package cn.xopencode.oss.manager.sms;

import cn.xopencode.oss.rpc.sms.dto.UserSendSmsCodeReqDTO;
import cn.xopencode.oss.rpc.sms.dto.UserVerifySmsCodeReqDTO;
import cn.xopencode.oss.service.sms.UserSmsCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserSmsCodeManager {

    @Autowired
    private UserSmsCodeService userSmsCodeService;

    public String sendSmsCode(UserSendSmsCodeReqDTO sendSmsCodeDTO) {
        // 生成短信验证码
        String smsCode = userSmsCodeService.createSmsCode(sendSmsCodeDTO.getMobile(), sendSmsCodeDTO.getScene(), sendSmsCodeDTO.getIp());
        // TODO 调用发送程序发送验证码
        return smsCode;
    }

    public void verifySmsCode(UserVerifySmsCodeReqDTO verifySmsCodeDTO) {
        userSmsCodeService.verifySmsCode(verifySmsCodeDTO.getMobile(), verifySmsCodeDTO.getCode(),
                verifySmsCodeDTO.getScene(), verifySmsCodeDTO.getUsedIp());
    }

}
